﻿namespace MVCResourceEngine
{
    using System;
    using System.Collections.Generic;

    /// <summary>
    /// Represents the result of locating a resource engine.
    /// </summary>
    public class ResourceEngineResult
    {
        /// <summary>
        /// Gets or sets the searched locations.
        /// </summary>
        /// <value>The searched locations.</value>
        public IEnumerable<string> SearchedLocations { get; private set; }

        /// <summary>
        /// Gets or sets the virtual path of the resource.
        /// </summary>
        /// <value>The virtual path of the resource.</value>
        public string Resource { get; private set; }

        /// <summary>
        /// Gets or sets the resource engine.
        /// </summary>
        /// <value>The resource engine.</value>
        public IResourceEngine ResourceEngine { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceEngineResult"/> class.
        /// </summary>
        /// <param name="searchedLocations">The searched locations.</param>
        public ResourceEngineResult(IEnumerable<string> searchedLocations)
        {
            // throw exception if searched locations is null
            if (searchedLocations == null)
                throw new ArgumentNullException("searchedLocations");

            // set searched locations
            this.SearchedLocations = searchedLocations;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceEngineResult"/> class.
        /// </summary>
        /// <param name="resource">The virtual path of the resource.</param>
        /// <param name="resourceEngine">The resource engine.</param>
        public ResourceEngineResult(string resource, IResourceEngine resourceEngine)
        {
            // throw exception if resource is null
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            // throw exception if resource engine is null
            if (resourceEngine == null)
            {
                throw new ArgumentNullException("resourceEngine");
            }

            // set resource
            this.Resource = resource;

            // set resource engine
            this.ResourceEngine = resourceEngine;
        }
        
    }
}
